package pl.puntin.punclient.messages;

public final class LoginMessage extends Message
{

	private final String login;

	public LoginMessage(final String login)
	{
		this.login = login;
	}

	@Override
	public byte getType()
	{
		return MessageTypes.C_LOGIN;
	}

	@Override
	public byte[] getByteForm()
	{
		byte[] byteForm = new byte[login.length()+1];
		for (int i = 0; i < byteForm.length; i++)
		{
			if(i == 0) byteForm[i] = getType();
			else
			{
				byteForm[i] = (byte) login.charAt(i-1);
			}
		}
		return byteForm;
	}

}
